Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(autocomplete): type for 'title' prop in AutocompleteSection #3959

Open
wants to merge 2 commits into
base: canary
Choose a base branch
from

Conversation

ritikpal1122
Copy link

@ritikpal1122 ritikpal1122 commented Oct 29, 2024

Closes #3911

📝 Description

This PR adds a type definition for the title prop in the AutocompleteSection component. This change enhances type safety and improves the developer experience by providing better autocompletion and error checking in TypeScript.

⛳️ Current behavior (updates)

Currently, the title prop in the AutocompleteSection component does not have a defined type, which can lead to potential runtime errors and confusion for developers using the component.

🚀 New behavior

With this PR, the title prop is now defined with a specific type, ensuring that it accepts only valid values. This change will help prevent errors and provide clearer documentation for developers.

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

  • This change was motivated by feedback from developers who encountered issues with the lack of type safety in the AutocompleteSection component.
  • Additional tests have been added to verify the correct behavior of the title prop.
  • Documentation has been updated to reflect the new type definition.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Enhanced ListboxSectionBaseProps interface to include children and title properties for better customization in listbox sections.
    • Updated SectionProps type to allow for more flexible omission of properties, improving component construction and customization options.
    • | title | string | The title of the listbox section. | - |

Copy link

changeset-bot bot commented Oct 29, 2024

⚠️ No Changeset found

Latest commit: cfaed1a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Oct 29, 2024

@ritikpal1122 is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

Walkthrough

The changes in this pull request involve updates to the ListboxSectionBaseProps interface and the SectionProps type. The ListboxSectionBaseProps now inherits from SectionProps with additional generic parameters for "children" and "title." The SectionProps type has also been modified to include a new generic parameter, OmitKeys, allowing for greater flexibility in omitting properties from the HTMLNextUIProps type. These modifications enhance the structure and usability of the listbox components.

Changes

File Change Summary
packages/components/listbox/src/base/listbox-section-base.tsx Updated ListboxSectionBaseProps to inherit from SectionProps with new generic parameters "children" and "title."
packages/utilities/aria-utils/src/collections/section.ts Modified SectionProps type to include a third generic parameter OmitKeys, allowing omission of "children" and "title."

Assessment against linked issues

Objective Addressed Explanation
Fix type of 'title' prop in AutocompleteSection component (#3911)

Possibly related PRs

Suggested reviewers

  • wingkwong
  • jrgarciadev

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 11af372 and cfaed1a.

📒 Files selected for processing (1)
  • packages/components/listbox/src/base/listbox-section-base.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/components/listbox/src/base/listbox-section-base.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8de427b and 11af372.

📒 Files selected for processing (2)
  • packages/components/listbox/src/base/listbox-section-base.tsx (1 hunks)
  • packages/utilities/aria-utils/src/collections/section.ts (1 hunks)
🧰 Additional context used
🪛 Biome
packages/components/listbox/src/base/listbox-section-base.tsx

[error] 8-8: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)

packages/utilities/aria-utils/src/collections/section.ts

[error] 11-11: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)

🔇 Additional comments (2)
packages/utilities/aria-utils/src/collections/section.ts (1)

9-13: LGTM! Type enhancement improves flexibility and type safety.

The addition of the OmitKeys generic parameter with default values "children" | "title" provides better type control and aligns well with the PR's objective of improving type safety.

🧰 Tools
🪛 Biome

[error] 11-11: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)

packages/components/listbox/src/base/listbox-section-base.tsx (1)

8-9: LGTM! Good improvement in type safety.

The explicit type parameters for "children" and "title" in the SectionProps extension enhance type safety and provide better TypeScript support, which directly addresses the PR objective.

🧰 Tools
🪛 Biome

[error] 8-8: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)

@wingkwong wingkwong changed the title feat: add type for 'title' prop in AutocompleteSection component fix(autocomplete): type for 'title' prop in AutocompleteSection Oct 29, 2024
Copy link
Member

@ryo-manba ryo-manba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!
Please also update the documentation.

| title | `string` | The title of the listbox section. | - |

@ritikpal1122 ritikpal1122 reopened this Nov 7, 2024
Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a changeset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Fix type of 'title' prop in AutocompleteSection component
3 participants